#include "Perspective.h"

Perspective::Perspective( float near,float far, float angle, float fromX, float fromY, float fromZ, float toX, float toY, float toZ )
{
	this->near=near;
	this->far=far;
	this->angle=angle;
	this->fromX=fromX;
	this->fromY=fromY;
	this->fromZ=fromZ;
	this->toX=toX;
	this->toY=toY;
	this->toZ=toZ;

	
}

void Perspective::act()
{
	extern float xy_aspect;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluPerspective(angle, xy_aspect, near,far);
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
	if(toX==fromX && toZ==fromZ)
		gluLookAt(fromX,fromY,fromZ,toX,toY,toZ,1,0,0);
	else
		gluLookAt(fromX,fromY,fromZ,toX,toY,toZ,0,1,0);

}
